feat(pai): separate pai command from opencode#104
feat(pai): separate pai command from opencode#104Steffen025 merged 5 commits intoSteffen025:mainfrom
Conversation
…fix content loading for "pai"
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 10 minutes and 34 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
.opencode/package.json declares "type": "module", which means the
CommonJS globals __dirname / __filename are not defined at runtime in
.opencode/plugins/pai-unified.ts. The original fix introduced a
ReferenceError that would trigger the first time loadMinimalBootstrap()
was called after a user ran the 'pai' command.
Replaced with the ESM-idiomatic pattern:
import { fileURLToPath } from 'node:url';
const PLUGIN_DIR = path.dirname(fileURLToPath(import.meta.url));
PLUGIN_DIR is now resolved once at module load and reused inside
loadMinimalBootstrap(). Same intent as the original fix (resolve PAI
dir relative to plugin location, not cwd) — just compatible with
the ESM module system.
Co-authored-by: eddovandenboom <eddovandenboom@users.noreply.github.com>
|
Hey @eddovandenboom — thank you so much for this contribution! 🙏 This PR does two genuinely valuable things:
One adjustment I pushedI hope you don't mind — I pushed a small fix on top of your branch (commit The ESM-idiomatic replacement is: import { fileURLToPath } from "node:url";
const PLUGIN_DIR = path.dirname(fileURLToPath(import.meta.url));I resolved Your commit is preserved intact — my fix is a follow-up commit on top with Context: PR #107 is about to shipWhile we wait for CodeRabbit's review of my follow-up commit, a heads up: we're preparing to ship PAI-OpenCode v3.0 very soon (targeting tomorrow). The big piece of v3.0 is PR #107 — the "Vanilla OpenCode Migration" that drops the custom Your changes don't conflict with #107 (different files), so after CodeRabbit green-lights the follow-up commit here, this PR can merge independently and ship alongside #107 in v3.0. CreditYou'll be credited in the v3.0 CHANGELOG release notes as one of two community contributors who made this release possible (@ktneely is the other — he fixed the stale OpenCode Zen model roster in #103, integrated into #107). Both contributions landed in exactly the right week. 🎉 If you'd like a different attribution name or link (e.g., your site, social handle), let me know and I'll update the CHANGELOG entry before we tag v3.0. Thanks again — community PRs like this one, where a contributor identifies a real UX gap and ships a clean fix for it, are exactly what healthy OSS looks like. 🚀 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.gitignore:
- Around line 19-21: The .gitignore currently includes an unnecessary exception
for "!.opencode/PAI/USER/.gitkeep" which does not exist; remove that line so the
block keeps only the ignore for ".opencode/PAI/USER/*" and the README exception
"!.opencode/PAI/USER/README.md". Update the .gitignore by deleting the
"!.opencode/PAI/USER/.gitkeep" entry (leaving ".opencode/PAI/USER/*" and
"!.opencode/PAI/USER/README.md") and re-evaluate whether any subdirectories
(ACTIONS, BUSINESS, FLOWS, etc.) need their own keep files if they should be
tracked.
In @.opencode/PAI/Tools/pai.ts:
- Around line 462-466: The spawn call that sets PAI_ENABLED for cmdLaunch only
causes cmdPrompt to run without the PAI context gate; update cmdPrompt's spawn
(or the shared launcher) to include env: { ...process.env, PAI_ENABLED: "1" } so
both cmdLaunch and cmdPrompt run with the plugin bootstrap/context injection
enabled (alternatively factor the spawn options into a shared helper used by
cmdLaunch and cmdPrompt to ensure the PAI_ENABLED env var is always set).
In @.opencode/plugins/pai-unified.ts:
- Around line 394-400: The gating currently treats any non-empty PAI_ENABLED
value as enabled inside the experimental.chat.system.transform handler; change
the condition to explicitly check for the wrapper contract value
(process.env.PAI_ENABLED !== "1") so only "1" enables PAI context, and update
the log message if needed to reflect the explicit check; locate the check inside
the experimental.chat.system.transform function and replace the loose truthy
test with the explicit comparison.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9e1c72c8-a658-4bf1-983c-823f4e8aa6a6
📒 Files selected for processing (3)
.gitignore.opencode/PAI/Tools/pai.ts.opencode/plugins/pai-unified.ts
…ENABLED check
Three findings from CodeRabbit, all verified and fixed.
- .gitignore: remove the spurious '!.opencode/PAI/USER/.gitkeep' exception.
The .gitkeep file does not exist in PAI/USER/ (only README.md and several
real directories like ACTIONS, BUSINESS, FLOWS, etc.). The exception was
modelled on the .opencode/USER/ block which does ship a .gitkeep, but
PAI/USER/ does not. The block is now:
.opencode/PAI/USER/*
!.opencode/PAI/USER/README.md
- .opencode/PAI/Tools/pai.ts: cmdPrompt was missing PAI_ENABLED: '1' in its
spawn env, so one-shot headless prompts (e.g. 'pai -p "..."') ran without
the plugin injecting PAI context. Added the same env flag that cmdLaunch
already had so both interactive and prompt modes load the full PAI bootstrap.
- .opencode/plugins/pai-unified.ts: the PAI_ENABLED gate used a loose truthy
check (!process.env.PAI_ENABLED) which would enable context injection for
any non-empty value, including 'PAI_ENABLED=0' or 'PAI_ENABLED=false'.
Replaced with an explicit strict equality check (process.env.PAI_ENABLED
!== '1') that only activates for exactly the string '1', matching the
contract set by the pai wrapper. Updated the log message accordingly.
Co-authored-by: eddovandenboom <eddovandenboom@users.noreply.github.com>
Summary
Separates the "pai" command from "opencode" command with proper context loading and fixes content loading for "pai".
Changes
Summary by CodeRabbit